#include "stdafx.h"
#include "StructureAndConst.h"
#include "SpriteAnger.h"
#include "SpriteSingleFrame.h"
#include "SpriteMultiFrame.h"
#include "SpriteStaticPercent.h"
#include "DisplayController.h"

SpriteAnger::SpriteAnger(int nLayer):BaseDispSprite(nLayer,true,false),
	m_pAngerEmpty(NULL),m_pAngerHarf(NULL),m_pAngerFull(NULL),m_nAnger(0)
{
	LPDIRECT3DTEXTURE9 pTexture=NULL;
	CREATE_SPRITE_STATIC_PERCENT(m_pAngerHarf,ptPLAYER_ANGRY_HARF,picPLAYER_ANGRY_HARF,nLayer,true,false,JUDGE_POINTER_RE_VOID);
	m_pAngerHarf->m_vPosition=posPLAYER_ENGRY;
	m_pAngerHarf->SetDispSide(eHitBottom);

	CREATE_SPRITE_SINGLE_FRAME(m_pAngerEmpty,ptPLAYER_ANGRY_EMPTY,picPLAYER_ANGRY_EMPTY,nLayer,true,false,JUDGE_POINTER_RE_VOID)
	m_pAngerEmpty->m_vPosition=posPLAYER_ENGRY;

	CREATE_SPRITE_MULTI_FRAME(m_pAngerFull,ptPLAYER_ANGRY_FULL,picPLAYER_ANGRY_FULL,nLayer,-1,true,false,JUDGE_POINTER_RE_VOID)
	m_pAngerFull->m_vPosition=posPLAYER_ENGRY_FULL;
}


SpriteAnger::~SpriteAnger(void)
{
	SAFE_DELETE(m_pAngerEmpty)
	SAFE_DELETE(m_pAngerFull)
}

bool SpriteAnger::Draw( DWORD dwCurrentTime )
{
	int n=m_nAnger/NAngerFull;
	int i=0;
	for (i=0;i<n;i++)
	{
		m_pAngerFull->m_vPosition.x=i*NAngerIntervalX+posPLAYER_ENGRY_FULL.x;
		m_pAngerFull->Draw(dwCurrentTime);
	}

	int m=m_nAnger%NAngerFull;
	if (0!=m){
		m_pAngerEmpty->m_vPosition.x=n*NAngerIntervalX+posPLAYER_ENGRY.x;
		m_pAngerEmpty->Draw(dwCurrentTime);

		m_pAngerHarf->m_vPosition.x=m_pAngerEmpty->m_vPosition.x;
		m_pAngerHarf->m_vPosition.y=m_pAngerEmpty->m_vPosition.y+picPLAYER_ANGRY_HARF.nHeight-m;
		m_pAngerHarf->SetDrawingPercent((float)m/(float)NAngerFull);
		m_pAngerHarf->Draw(dwCurrentTime);
	}

	return true;
}